//
//  LZSearchAlbumTableViewCell.m
//  沙哈拉FM
//
//  Created by dllo on 15/11/12.
//  Copyright © 2015年 S1mpl3. All rights reserved.
//

#import "LZSearchAlbumTableViewCell.h"
#import "FitHeader.h"
#import "UIImageView+WebCache.h"
#import "Model.h"
@implementation LZSearchAlbumTableViewCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        [self createView];
        [self changeColor];
    }
    return self;
}

-(void)changeColor{
    self.backgroundColor = [Model shareInstance].ViewColor;
}


- (void)createView{
    
    _cover_pathImageView = [[UIImageView alloc]init];
    [self.contentView addSubview:_cover_pathImageView];
    
    _titleLabel = [[BaseLabel alloc]init];
    _titleLabel.font = [UIFont systemFontOfSize:16];
    [self.contentView addSubview:_titleLabel];
    
    _introLabel = [[BaseLabel alloc]init];
    _introLabel.textColor = [UIColor lightGrayColor];
    _introLabel.font = [UIFont systemFontOfSize:13];
    [self.contentView addSubview:_introLabel];
    
    _playImageView = [[UIImageView alloc]init];
    [self.contentView addSubview:_playImageView];
    
    _playLabel = [[BaseLabel alloc]init];
    _playLabel.textColor = [UIColor lightGrayColor];
    _playLabel.font = [UIFont systemFontOfSize:13];
    [self.contentView addSubview:_playLabel];
    
    _tracksImageView = [[UIImageView alloc]init];
    [self.contentView addSubview:_tracksImageView];
    
    _tracksLabel = [[BaseLabel alloc]init];
    _tracksLabel.textColor = [UIColor lightGrayColor];
    _tracksLabel.font = [UIFont systemFontOfSize:13];
    [self.contentView addSubview:_tracksLabel];
    
}
- (void)layoutSubviews{
    [super layoutSubviews];
    _cover_pathImageView.frame = CGRectMake(10 * FITWidth, 10 * FITHeight, 100 * FITWidth, 100 * FITHeight);
    _titleLabel.frame = CGRectMake(_cover_pathImageView.frame.origin.x + _cover_pathImageView.frame.size.width + 10 * FITWidth, _cover_pathImageView.frame.origin.y, 220 * FITWidth, 30 * FITHeight);
    _introLabel.frame = CGRectMake(_titleLabel.frame.origin.x, _titleLabel.frame.origin.y + _titleLabel.frame.size.height + 10, _titleLabel.frame.size.width, 30 * FITHeight);
    _playImageView.frame = CGRectMake(_introLabel.frame.origin.x, _introLabel.frame.size.height + _introLabel.frame.origin.y + 10 * FITHeight, 8 * FITWidth, 8 * FITHeight);
    _playLabel.frame = CGRectMake(_playImageView.frame.origin.x + _playImageView.frame.size.width, _playImageView.frame.origin.y - 10 * FITHeight, 50 * FITWidth, 30 * FITHeight);
    _tracksImageView.frame = CGRectMake(_playLabel.frame.origin.x + _playLabel.frame.size.width + 5 * FITWidth, _playImageView.frame.origin.y, _playImageView.frame.size.width, _playImageView.frame.size.height);
    _tracksLabel.frame = CGRectMake(_tracksImageView.frame.origin.x + _tracksImageView.frame.size.width, _tracksImageView.frame.origin.y - 10 * FITHeight, _playLabel.frame.size.width, _playLabel.frame.size.height);
    
    _playImageView.image = [UIImage imageNamed:@"S1mpl3播放"];
    _tracksImageView.image = [UIImage imageNamed:@"iconfont-jishu"];
}
- (void)setLzSearchAlbum:(LZSearchAlbum *)lzSearchAlbum{
    if (_lzSearchAlbum != lzSearchAlbum) {
        _lzSearchAlbum = lzSearchAlbum;
    }
    [_cover_pathImageView sd_setImageWithURL:[NSURL URLWithString:lzSearchAlbum.cover_path] placeholderImage:[UIImage imageNamed:@"100*100"]];
    _titleLabel.text = lzSearchAlbum.title;
    if ([_playLabel.text integerValue] < 10000.0) {
        _playLabel.text = [NSString stringWithFormat:@"%@", lzSearchAlbum.play];
    }else{
        _playLabel.text = [NSString stringWithFormat:@"%.1f万", [lzSearchAlbum.play integerValue] / 10000.0];
    }
    
    _tracksLabel.text = [NSString stringWithFormat:@"%@集", lzSearchAlbum.tracks];
    _introLabel.text = lzSearchAlbum.intro;
    [self changeColor];
}
@end
